package com.sam.demo.controller;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.sam.demo.entity.User;
import com.sam.demo.service.UserService;

@Controller
@RequestMapping(value = "/users")
public class UserController {

	@Autowired
	private UserService userService;
	
	/**
	 * 请求转发到login.jsp
	 * @return
	 */
	@RequestMapping(value = "/show1", method = RequestMethod.GET)
	public String show1() {
		return "login";
	}

	/**
	 * 重定向到login.jsp
	 * @return
	 */
	@RequestMapping(value = "/show2", method = RequestMethod.GET)
	public String show2() {
		return "redirect:/jsp/login.jsp";
	}

	@RequestMapping(value = "/show3", method = RequestMethod.GET)
	@ResponseBody
	public User show3() {
		User user = userService.findOne(1L);
		return user;
	}
	
	/**
	 * 请求转发到user.html
	 * @return
	 */
	@RequestMapping(value = "/show4", method = RequestMethod.GET)
	public String show4() {
		return "redirect:/user.html";
	}


}
